import java.util.Random;


public class BasicFinder {
	static int[] board;
	public static void main(String[] args) {
		//debug();
		init();
		calc();
	}
	static void debug() {
		System.out.println(missingCard(102, 2010));
		int i=1/0;
	}
	static void init() {
		/*int[] tboard = {102, 2010, 1221,
						  1201, 2012, 12,
						  120, 2110, 1122,
						  10, 2121, 1002};*/
		int[] tboard = new int[12];
		Random rand = new Random();
		int v;
		for (int i=0 ;i<12; i++) {
			v=0;
			for (int j=0 ;j<4; j++) {
				v*=10;
				v+=rand.nextInt(3);
			}
			tboard[i]=v;
		}
		for (int i=0 ;i<4; i++) {
			for (int j=0; j<3; j++) {
				System.out.print(tboard[3*i+j]+"\t");
			}
			System.out.println();
		}
		board=tboard;
	}
	static void calc() {
		int v1, v2, v3;
		for (int c1=0; c1<12; c1++) {
			v1=board[c1];
			for (int c2=c1+1; c2<12; c2++) {
				v2=board[c2];
				v3=missingCard(v1, v2);
				for (int c3=c2+1; c3<12; c3++) {
					if (v3==board[c3]) {
						System.out.println(""+(c1+1)+" "+(c2+1)+ " "+(c3+1));
					}
					if (c1==0 && c2==1 && c3==2) {
					}
				}
			}
		}
	}
	static int missingCard(int first, int second) {
		int t1, t2, ans=0, mult=1;
		for (int i=0 ;i<4; i++) {
			t1=first%10;
			t2=second%10;
			if (t1==t2) {
				ans+=t1*mult;
			} else if (t1+t2==1) {
				ans+=2*mult;
			} else if (t1+t2==2) {
				ans+=mult;
			}
			mult*=10;
			first/=10;
			second/=10;
		}
		return ans;
	}
}
